package com.hitqz.robot.biz.flow.component.common;

import com.hitqz.robot.driver.model.IRobotPosDto;
import com.hitqz.robot.driver.parent.RobotDriverService;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

@Slf4j
@LiteflowComponent(value = "CancelChange", name = "[通用组件]取消充电")
@AllArgsConstructor
public class CancelChange extends NodeComponent {

    private final RobotDriverService robotDriverService;

    @Override
    public void process() throws Exception {
        IRobotPosDto webPos = robotDriverService.getWebPos();
        String currentDirection = webPos.getCurrentDirection();
        if (Objects.equals(currentDirection, "充电")){
            robotDriverService.cmdCharge(0);
            log.info("取消充电");
        }
    }
}